import { getSearchConditions, getSearchHouse, getGuessulike, keywordsearchsuggest } from "@/services/modules/search";
import { defineStore } from "pinia";

const useSearchStore = defineStore("search", {
    state: () => {
        return {
            searchList: {},
            searchHouse: {},
            guessulike: {},
            searchsuggest: []
        }
    },
    actions: {
        async fetchSearchConditions() {
            const res = await getSearchConditions()
            this.searchList = res.data.data.allConditions || {}
        },
        async fetchSearchHouse() {
            const res = await getSearchHouse()
            this.searchHouse = res?.data?.data || {}
        },
        async fetchGuessulike() {
            const res = await getGuessulike()
            this.guessulike = res?.data || {}
        },
        async fetchKeywordsearchsuggest(keyword) {
            const res = await keywordsearchsuggest(keyword)
            this.searchsuggest = res?.data?.suggests || []
        }
    }
})

export default useSearchStore